package com.jh.user.service;

import cn.jh.common.exception.ServiceException;
import cn.jh.common.utils.CommonsUtil;
import com.jh.user.business.CongMingRateBussiness;
import com.jh.user.util.Commons;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Service;
import java.util.List;
import java.util.Map;

@RestController
public class CongMingRateService {
    private static final Logger log = LoggerFactory.getLogger(CongMingRateService.class);

    @Autowired
    private CongMingRateBussiness congMingRateBussiness;

    /**
     * 根据shopId获取商户的快银支付个人费率列表
     * @param shopId 开店关机的shopId
     * @return
     */
    @PostMapping(value = "/v1.0/user/congmingrate/getcongmingratelistbyshopid")
    public Object getCongMingRateListByShopId(String shopId) {
        if (StringUtils.isEmpty(shopId)) {
            return CommonsUtil.returnError("商户id为空！");
        }
        try {
            List<Map<String, String>> list = congMingRateBussiness.getCongMingRateListByShopId(shopId);
            return CommonsUtil.returnSuccess("获取费率列表成功！", list);
        } catch (ServiceException e) {
            e.printStackTrace();
            return CommonsUtil.returnError(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return CommonsUtil.returnError("服务器异常，请稍后再试！");
        }
    }
}
